/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package utility;

import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;

public class ListComboBoxModel extends AbstractListModel implements ComboBoxModel {

  String _selection = null;
  String[] _list;

  public ListComboBoxModel(){}
  public ListComboBoxModel(String[] _array)
  {
      _list = _array;
  }

  @Override
  public Object getElementAt(int index) {
    return _list[index];
  }

  @Override
  public int getSize() {
    return _list.length;
  }

  @Override
  public void setSelectedItem(Object anItem) {
    _selection = (String) anItem; // to select and register an
  } // item from the pull-down list

  // Methods implemented from the interface ComboBoxModel
  @Override
  public Object getSelectedItem() {
    return _selection; // to add the selection to the combo box
  }
}
